﻿namespace ClassyBlog.DataAccess.Specs.Unit
{
    using Machine.Specifications;
    using NSubstitute;

    using DomainObjects;
    using Infrastructure;

    [Subject(typeof(PostFactory))]
    public class when_post_is_created
    {
        const string DataPath =
            @"c:\inetpub\wwwroot\classyblog\app_data\posts";

        const string FileName = "2010-04-02-17-30-00_hello-world.md";

        static IFileSystem fileSystem;
        static PostFactory factory;

        static Post post;

        Establish context = () =>
        {
            fileSystem = Substitute.For<IFileSystem>();
            fileSystem.FileExists(Arg.Any<string>()).Returns(true);

            factory = new PostFactory(fileSystem);
        };

        Because of = () =>
            post = factory.Create(DataPath, DataPath + "/" + FileName);

        It should_return_lazy_post = () => post.ShouldBeOfType<LazyPost>();
    }
}